home *** CD-ROM | disk | FTP | other *** search
/ Programming Windows (5th Edition) / Programming Windows, 5th ed. - Companion CD (097-0002183)(1999).iso / Chap17 / EZTest / EZTest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-09  |  1.6 KB  |  51 lines

  1. /*---------------------------------------
  2.    EZTEST.C -- Test of EZFONT
  3.                (c) Charles Petzold, 1998
  4.   ---------------------------------------*/
  5.  
  6. #include <windows.h>
  7. #include "ezfont.h"
  8.  
  9. TCHAR szAppName [] = TEXT ("EZTest") ;
  10. TCHAR szTitle   [] = TEXT ("EZTest: Test of EZFONT") ;
  11.  
  12. void PaintRoutine (HWND hwnd, HDC hdc, int cxArea, int cyArea)
  13. {
  14.      HFONT      hFont ;
  15.      int        y, iPointSize ;
  16.      LOGFONT    lf ;
  17.      TCHAR      szBuffer [100] ;
  18.      TEXTMETRIC tm ;
  19.  
  20.           // Set Logical Twips mapping mode
  21.  
  22.      SetMapMode (hdc, MM_ANISOTROPIC) ;
  23.      SetWindowExtEx (hdc, 1440, 1440, NULL) ;
  24.      SetViewportExtEx (hdc, GetDeviceCaps (hdc, LOGPIXELSX),
  25.                             GetDeviceCaps (hdc, LOGPIXELSY), NULL) ;
  26.  
  27.           // Try some fonts
  28.  
  29.      y = 0 ;
  30.  
  31.      for (iPointSize = 80 ; iPointSize <= 120 ; iPointSize++)
  32.      {
  33.           hFont = EzCreateFont (hdc, TEXT ("Times New Roman"), 
  34.                                 iPointSize, 0, 0, TRUE) ;
  35.  
  36.           GetObject (hFont, sizeof (LOGFONT), &lf) ;
  37.  
  38.           SelectObject (hdc, hFont) ;
  39.           GetTextMetrics (hdc, &tm) ;
  40.  
  41.           TextOut (hdc, 0, y, szBuffer, 
  42.                wsprintf (szBuffer, 
  43.                          TEXT ("Times New Roman font of %i.%i points, ")
  44.                          TEXT ("lf.lfHeight = %i, tm.tmHeight = %i"),
  45.                          iPointSize / 10, iPointSize % 10,
  46.                          lf.lfHeight, tm.tmHeight)) ;
  47.  
  48.           DeleteObject (SelectObject (hdc, GetStockObject (SYSTEM_FONT))) ;
  49.           y += tm.tmHeight ;
  50.      }
  51. }